
public class Pila {

    int v[];
    int tos;

    Pila() {
        v = new int[10];
        tos = -1;
    }

    void crece() {
        int tmp[];
        if (tos == v.length - 1) {
            tmp = new int[v.length + 5];
            for (int k = 0; k < v.length; k++) {
                tmp[k] = v[k];
            }
            v = tmp;

        }
    }

    void push(int c) {
        crece();
        tos++;
        v[tos] = c;
    }

    int pop() {
        int c = 0;
        if (tos >= 0) {
            c = v[tos];
            tos--;
        }
        return c;
    }

    boolean vacio() {
        return tos == -1;
    }
}
